<?php
session_start();
include_once('../../../php/include_all.php');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../../../css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="../../../css/DT_bootstrap.css">
<link href="../../../css/bootstrap-responsive.min.css" rel="stylesheet">
<link href="../../../css/style-tambahan.css" rel="stylesheet">
	<script src="../../../js/bootbox.min.js"></script>
	<script src="../../../js/jquery.js"></script>
	<script src="../../../js/bootstrap.min.js"></script>
	<script type="text/javascript" charset="utf-8" language="javascript" src="../../../js/jquery.dataTables.js"></script>
	<script type="text/javascript" charset="utf-8" language="javascript" src="../../../js/DT_bootstrap.js"></script>
</head>

<body>
<div class="row-fluid">
<?php
	$tahun = date('Y');
	$tahunKurang = 4;
	$tahun1 = $tahun - $tahunKurang;
	if ($_GET['id'] == 'SKPD01'){
		$judul= 'Laporan RKPD Awal SKPD';
		echo "<input type='hidden' name='co' id='co' value='SKPD01'>";
	}else if ($_GET['id'] == 'SKPD02'){
		$judul = 'Laporan RKPD Akhir SKPD';
		echo "<input type='hidden' name='co' id='co' value='SKPD02'>";
	}else if ($_GET['id'] == 'SKPD03'){
		$judul = 'Laporan Kegiatan Kecamatan';
		echo "<input type='hidden' name='co' id='co' value='SKPD03'>";
		$skpd =  "<tr>
                            <td style='width:100px;'>Kecamatan</td>
                            <td>
                                <select name='kec' id='kec' class='kec'>
                                </select>  
								 <span id='alerti' style='margin-left: 13px;padding-bottom:3px;'></span>
							</td>
                        </tr>";
	}else if ($_GET['id'] == 'SKPD04'){
		$judul = 'Laporan Usulan Kegiatan SKPD yang belum mengarah ke RPJM';
		echo "<input type='hidden' name='co' id='co' value='SKPD04'>";
	}
?>
	<div class="box span12 geo-box">
    	<div class="box-header well" ><h2><?php echo $judul; ?></h2></div>
        <div class="box-content">
        	<table class="table-form">
            	<tr>
                	<td style="width:100px;">SKPD</td>
                    <td>	
                    	<select name="skpd" id="skpd" class="skpd" onchange="skpd">
                        	<option id="" value="">-Pilih Salah Satu-</option>
                            <?php
                            $skpd =get_datas("select * from mus_skpd");
							foreach ($skpd as $skpd){
							?>
                            <option value="<? echo $skpd ['id_skpd'];?>"><? echo $skpd['nama_skpd'];?></option>
                            <?php
                            }
							?>
                        </select>
                    </td>
                </tr>
				<tr>
                    <td>Tahun</td>
                    <td>
                    	<select name="tahun" id="tahun" class="tahun">
                            <option value="0" id="">-Pilih Salah Satu-</option>
							<?php
							for($i=$tahun; $i>=$tahun1; $i--){
							?>
							<option value="<?php echo $i ?>"><?php echo $i?></option>
							<?php
							}
							?>
                        </select>                                
					</td>
                </tr>   
						<tr>
							<td></td>
							<td> <a class="btn btn-primary tombolCari" onClick="laporan()"><span id="loader" class="pull-left" ></span>&nbsp; Cari &nbsp;&nbsp;</a>
								<span id="result"></span>
							</td>
						<tr>
             </table>
					<br />
					<table cellpadding="0" cellspacing="0" border="0" class="table table-bordered geo-table" id="example">
						<thead>
							<tr>
								<th rowspan="2" style="text-align:center; vertical-align:middle;">No.</td>
								<th rowspan="2" style="text-align:center; vertical-align:middle;">Prioritas</td>
								<th rowspan="2" style="text-align:center; vertical-align:middle;">Program/Kegiatan</td>
								<th style="text-align:center;">Indikator Program</td>
								<th colspan="4" style="text-align:center;">Indikator Kegiatan</td>
								<th rowspan="2" style="text-align:center; vertical-align:middle;">Organisasi</td>
								<th colspan="4" style="text-align:center;">Pagu Indikatif</td>
								<th rowspan="2" style="text-align:center; vertical-align:middle;">Lokasi</td>
							</tr>
							<tr>
								<th style="text-align:center;">Hasil</th>
								<th style="text-align:center;">Keluaran</th>
								<th style="text-align:center;">Target</th>
								<th style="text-align:center;">Hasil</th>
								<th style="text-align:center;">Target</th>
								<th style="text-align:center;">APBD KAB</th>
								<th style="text-align:center;">APBD PROV</th>
								<th style="text-align:center;">APBN</th>
								<th style="text-align:center;">Total</th>
							</tr>
						</thead>
						<tbody id="tbody-laporan">
						</tbody>
					</table>
					<div style="margin:10px;" class="pull-right">
						<a style="margin:10px;" class="btn btn-primary" href="printXLS.php" target="_blank">Print Excel</a>
						<a class="btn btn-primary" href="printPHP.php" target="_blank">Print</a>
					</div>
           </div>
    </div>
</div>
</body>
</html>
<script language="javascript" type="text/javascript">

$('.skpd').change(function(){
	source = "tools.php?id="+this.value;
	var coba=$.get(source)
	coba.done(function(data){
		$('#kec').html(data);
	})
	}
);

var a = $('#co').val();
var urls="laporan.php?code="+a;

function laporan() {
	var btn = $(this);
	var skpd = $('#skpd').val();
	var tahun= $('#tahun').val();
	if (a == 'SKPD03'){
	var kec = $('#kec').val();
	var post = $.post(urls, {act : 'tmpl_laporan',skpd:skpd, kec:kec, tahun:tahun });
	}else{
	var post = $.post(urls, {act : 'tmpl_laporan',skpd:skpd, tahun:tahun });
	}
	post.done(function(inc){
		var isi = inc.split('___');
		if(isi.length === 2){
			if (isi[0] == 'ok'){
				$('#tbody-laporan').html(isi[1]);
			}else if (isi[0] == 'err'){
				$('#alerti').removeClass().addClass('alert alert-error');
				$('#alerti').html('Error !!!' + isi[1]);
				setTimeout(function(){
					$('alerti').removeClass();
				}, 1500);
			}
		} else {
			$('#alerti').removeClass().addClass('alert alert error');
			$('#alerti').html('Gagal Mengambil data ');
			setTimeout(function () {
				$('#alerti').removeClass();
				$('#alerti').html('');
			}, 1500);
		}
	});

}
</script>